package cn.com.ddapp.ddm.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.com.ddapp.ddm.R;
import cn.com.ddapp.ddm.bean.GoodSortBean;


public class ClassFicationRootAdpter extends BaseAdapter {
    private Context mContext;
    private List<GoodSortBean.GoodSort> mLists ;
    private LayoutInflater layoutInflater;

    public ClassFicationRootAdpter(Context context,List<GoodSortBean.GoodSort> lists) {
        mContext = context;
        mLists = lists;
        layoutInflater=LayoutInflater.from(mContext);
    }

    @Override
    public int getCount() {
        return mLists != null ? mLists.size():0;
    }

    @Override
    public Object getItem(int i) {
        return mLists.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    public void clearStatu(){
        for(int i=0;i<mLists.size();i++){
//            mLists.get(i).
        }
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {
        ViewHolder holder=null;
        if(convertView == null){
            convertView= layoutInflater.inflate(R.layout.classfication_left_item,null);
            holder=new ViewHolder(convertView);
            convertView.setTag(holder);
            AutoUtils.auto(convertView);
        }else{
            holder= (ViewHolder) convertView.getTag();
        }

        holder.cf_root_name.setText(mLists.get(position).getName());

        return convertView;
    }


    static class ViewHolder{
        @BindView(R.id.cf_root_name)
        TextView cf_root_name;

        public ViewHolder(View view){
            ButterKnife.bind(this,view);
        }
    }
}
